package com.lc.pianostudent.conn;

import com.lc.pianostudent.bean.ShopBean;
import com.lc.pianostudent.bean.ShopIndexBean;
import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2018/2/22.
 */
@HttpInlet(Conn.GOODS_CHANGETYPE)
public class PostGoodsTypechange extends BaseAsyPost {

    public String user_id,type;
    public PostGoodsTypechange(AsyCallBack asyCallBack) {
        super(asyCallBack);
    }

    @Override
    protected PostGoodsTypechangeInfo parser(JSONObject object) throws Exception {
        if (object.optString("code").equals("200")) {

            PostGoodsTypechangeInfo info = new PostGoodsTypechangeInfo();



            JSONArray array = object.optJSONArray("goods");
            if(array != null || array.length() != 0){
                for(int i = 0;i<array.length();i++){
                    JSONObject jo = array.optJSONObject(i);
                    ShopBean shopBean = new ShopBean();
                    shopBean.setId(jo.optString("id"));
                    shopBean.setTitle(jo.optString("title"));
                    shopBean.setPicurl(jo.optString("picurl"));
                    shopBean.setPrice(jo.optString("price"));
                    shopBean.setTypeid(jo.optString("typeid"));
                    shopBean.setPicshow(jo.optString("picshow"));
                    info.shopList.add(shopBean);

                }
            }


            return info;

        } else {

            TOAST = object.optString("message");

        }

        return null;
    }

    public static class PostGoodsTypechangeInfo {

        public String code;
        public List<ShopBean> shopList = new ArrayList<>();
    }

}
